package com.example.newdemo.view.image.svg;

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.os.Build.VERSION;
import android.util.Log;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;


public class SimpleAssetResolver extends SVGExternalFileResolver {
    private static final String TAG = SimpleAssetResolver.class.getSimpleName();
    private AssetManager assetManager;
    private static final Set<String> supportedFormats = new HashSet(8);

    public SimpleAssetResolver(AssetManager assetManager) {
        supportedFormats.add("image/svg+xml");
        supportedFormats.add("image/jpeg");
        supportedFormats.add("image/png");
        supportedFormats.add("image/pjpeg");
        supportedFormats.add("image/gif");
        supportedFormats.add("image/bmp");
        supportedFormats.add("image/x-windows-bmp");
        if (VERSION.SDK_INT >= 14) {
            supportedFormats.add("image/webp");
        }

        this.assetManager = assetManager;
    }

    public Typeface resolveFont(String fontFamily, int fontWeight, String fontStyle) {
        Log.i(TAG, "resolveFont(" + fontFamily + "," + fontWeight + "," + fontStyle + ")");

        try {
            return Typeface.createFromAsset(this.assetManager, fontFamily + ".ttf");
        } catch (Exception var6) {
            try {
                return Typeface.createFromAsset(this.assetManager, fontFamily + ".otf");
            } catch (Exception var5) {
                return null;
            }
        }
    }

    public Bitmap resolveImage(String filename) {
        Log.i(TAG, "resolveImage(" + filename + ")");

        try {
            InputStream istream = this.assetManager.open(filename);
            return BitmapFactory.decodeStream(istream);
        } catch (IOException var3) {
            return null;
        }
    }

    public boolean isFormatSupported(String mimeType) {
        return supportedFormats.contains(mimeType);
    }
}
